﻿Imports System.Xml
Namespace GlobalClass
    Class CLanguage


        Public Shared dsConTrol As XmlNode ' danh sach control trong file xml
        Public Shared loaiNgonNgu As String = "V"


        ' Add some elements to the dictionary. There are no 
        ' duplicate keys, but some of the values are duplicates.



        Public Shared Sub LoadControl()

            Dim xmlDoc As New XmlDocument
            If loaiNgonNgu = "E" Then
                xmlDoc.Load("English.xml")
            Else
                xmlDoc.Load("Vietnam.xml")
            End If

            Dim nodeControl As XmlNodeList = xmlDoc.DocumentElement.ChildNodes
            dsConTrol = nodeControl(0)
        End Sub

        Public Shared Function ReadTextConTrol(ByVal nameOfCtr As String) As String
            Dim strText As String
            Try
                strText = dsConTrol.SelectSingleNode(nameOfCtr).InnerText
            Catch ex As Exception
                strText = ""
            End Try

            Return strText
        End Function

        Public Shared Sub ChangeTextControl(ByVal ctr As Control)
            If (ReadTextConTrol(ctr.Name) <> "") Then
                ctr.Text = ReadTextConTrol(ctr.Name)
            End If
            If (ctr.HasChildren) Then
                For Each ctrChild As Control In ctr.Controls
                    ChangeTextControl(ctrChild)
                Next
            End If

        End Sub
        

    End Class
End Namespace
